package sg.edu.nus.iss.cats.dataaccess;

import javax.servlet.ServletContext;

public abstract class DAOFactory {

	public abstract UserDAO getUserDAO();

	public abstract EmployeeDAO getEmployeeDAO();

	public abstract CourseDAO getCourseDAO();

	public abstract SequenceManager getSequenceManager();

	public abstract DepartmentDAO getDepartmentDAO();

	private static DAOFactory instance;

	private static int accessConfig = 1; // by default access DB

	protected static ServletContext servletCtxt;

	public static void setAccessTypeConfig(int access) {

		accessConfig = access;

	}

	public static void setCtxt(ServletContext ctxt) {
		servletCtxt = ctxt;

	}

	public static DAOFactory getInstance() {

		if (instance == null) {
			instance = loadInstance(accessConfig);
		}
		return instance;
	}

private static DAOFactory loadInstance (int accessConfig){
    
        System.out.println("***********DAOFactory : LOADING &&&&&&&&&&&&&&" + accessConfig);
       
    
        switch (accessConfig) {
        
           case (2):
                return new sg.edu.nus.iss.cats.dataaccess.hibernate.DAOFactoryImpl(); 
                
            default:
                return new sg.edu.nus.iss.cats.dataaccess.mysql.DAOFactoryImpl();

        }
    }}